home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Inspectors / link.js < prev    next >
Encoding:
Text File  |  1999-12-01  |  2.5 KB  |  97 lines

  1.  
  2. //form field names (all text fields):
  3. //Href
  4. //ID
  5. //Title
  6. //Rel
  7. //Rev
  8.  
  9. // *********** GLOBAL VARS *****************************
  10.  
  11. var helpDoc = MM.HELP_inspLink;
  12.  
  13. // ******************** API ****************************
  14. function canInspectSelection(){
  15.   return true;
  16. }
  17.  
  18. function inspectSelection(){
  19.   var Href = findObject("Href");
  20.   var Title = findObject("Title");
  21.   var ID = findObject("ID");
  22.   var Rel = findObject("Rel");
  23.   var Rev = findObject("Rev");
  24.   var linkObj = getSelectedObj();
  25.  
  26.   if (linkObj.getAttribute("href"))
  27.     Href.value=linkObj.getAttribute("href");
  28.   else
  29.     Href.value = "";    
  30.   if (linkObj.getAttribute("id"))
  31.     ID.value=linkObj.getAttribute("id");
  32.   else
  33.     ID.value = "";    
  34.   if (linkObj.getAttribute("title"))  
  35.     Title.value=linkObj.getAttribute("title");
  36.   else
  37.     Title.value="";    
  38.   if (linkObj.getAttribute("rel"))
  39.     Rel.value=linkObj.getAttribute("rel");
  40.   else
  41.     Rel.value = "";    
  42.   if (linkObj.getAttribute("rev"))
  43.     Rev.value=linkObj.getAttribute("rev");
  44.   else
  45.     Rev.value ="";    
  46.   showHideTranslated();;
  47.   //showHideTranslated( getSelectedObj(), 'tButtonSpan' );    
  48. }
  49.  
  50.  
  51.  
  52. // ******************** LOCAL FUNCTIONS ****************************
  53.  
  54. function setLinkTag(){
  55.   var linkObj = getSelectedObj();
  56.   var relValue = findObject("Rel").value;
  57.   var bRelEqualsStylesheet = relValue &&
  58.                              relValue.toLowerCase().indexOf("stylesheet")!=-1;
  59.   if (findObject("Href").value)
  60.     linkObj.setAttribute("href",findObject("Href").value);
  61.   else
  62.     linkObj.removeAttribute("href");
  63.   if (findObject("ID").value)
  64.     linkObj.setAttribute("id",findObject("ID").value);
  65.   else
  66.     linkObj.removeAttribute("id");
  67.   if (findObject("Title").value)
  68.     linkObj.setAttribute("title",findObject("Title").value);
  69.   else
  70.     linkObj.removeAttribute("title");
  71.   if (findObject("Rel").value)
  72.     linkObj.setAttribute("rel",findObject("Rel").value);
  73.   else
  74.     linkObj.removeAttribute("rel");
  75.   if (findObject("Rev").value)
  76.     linkObj.setAttribute("rev",findObject("Rev").value);
  77.   else
  78.     linkObj.removeAttribute("rev");
  79.   setTypeAttr(bRelEqualsStylesheet);//set type attribute based on rel value    
  80. }
  81.  
  82. function browseForFile(){
  83.   var fileName=browseForFileURL();
  84.   if (fileName) 
  85.     findObject("Href").value=fileName;
  86. }
  87.  
  88. function setTypeAttr(bStyle){
  89.   var linkObj = getSelectedObj();
  90.   var typeAttr = linkObj.getAttribute("type");
  91.   if (bStyle) //set type to text/css if applicable
  92.     linkObj.setAttribute("type","text/css");
  93.   //otherwise, remove it    
  94.   else if (typeAttr && typeAttr.toLowerCase() == "text/css")
  95.     linkObj.removeAttribute("type");
  96. }
  97.